package com.dries.portal.module.xxshop.controller;

import com.dries.common.api.CommonResult;
import com.dries.portal.module.xxshop.entity.Cartgoods;
import com.dries.portal.module.xxshop.service.ICartgoodsService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.Arrays;
import java.util.Map;

/**
 * 购物车货物
 *
 * @author dries
 * @email samphsanie@gmail.com
 * @date 2020-10-14 14:11:08
 */
@RestController
@RequestMapping("xxshop/cartgoods")
public class CartgoodsController {

    @Resource
    private ICartgoodsService cartgoodsService;

    /**
     * 列表
     */
    @GetMapping("/list")
    public CommonResult list(@RequestParam Map<String, Object> params){

        
        return CommonResult.success();
    }


    /**
     * 信息
     */
    @GetMapping("/info/{cartid}")
    public CommonResult info(@PathVariable("cartid") Long cartid){
		Cartgoods cartgoods = cartgoodsService.getById(cartid);

        return CommonResult.success();
    }

    /**
     * 保存
     */
    @PostMapping("/save")
    public CommonResult save(@RequestBody Cartgoods cartgoods){
		cartgoodsService.save(cartgoods);

        return CommonResult.success();
    }

    /**
     * 修改
     */
    @PutMapping("/update")
    public CommonResult update(@RequestBody Cartgoods cartgoods){
		cartgoodsService.updateById(cartgoods);

        return CommonResult.success();
    }

    /**
     * 删除
     */
    @DeleteMapping("/delete")
    public CommonResult delete(@RequestBody Long[] cartids){
		cartgoodsService.removeByIds(Arrays.asList(cartids));

        return CommonResult.success();
    }

}
